package com.ruoyi.slope.dataFile.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.slope.dataFile.domain.SlopeDataFile;
import com.ruoyi.slope.dataFile.service.ISlopeDataFileService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资料管理Controller
 * 
 * @author psy
 * @date 2025-04-25
 */
@RestController
@RequestMapping("/slope/dataFile")
public class SlopeDataFileController extends BaseController
{    
    @Autowired
    private ISlopeDataFileService slopeDataFileService;

    /**
     * 查询资料管理列表
     */
    @PreAuthorize("@ss.hasPermi('slope:dataFile:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlopeDataFile slopeDataFile)
    {
        startPage();
        List<SlopeDataFile> list = slopeDataFileService.selectSlopeDataFileList(slopeDataFile);
        return getDataTable(list);
    }

    /**
     * 导出资料管理列表
     */
    @PreAuthorize("@ss.hasPermi('slope:dataFile:export')")
    @Log(title = "资料管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlopeDataFile slopeDataFile)
    {
        List<SlopeDataFile> list = slopeDataFileService.selectSlopeDataFileList(slopeDataFile);
        ExcelUtil<SlopeDataFile> util = new ExcelUtil<SlopeDataFile>(SlopeDataFile.class);
        String path = util.exportExcel(response, list, "资料管理数据");
    }

    /**
     * 获取资料管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('slope:dataFile:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slopeDataFileService.selectSlopeDataFileById(id));
    }

    /**
     * 新增资料管理
     */
    @PreAuthorize("@ss.hasPermi('slope:dataFile:add')")
    @Log(title = "资料管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlopeDataFile slopeDataFile)
    {
        return toAjax(slopeDataFileService.insertSlopeDataFile(slopeDataFile));
    }

    /**
     * 修改资料管理
     */
    @PreAuthorize("@ss.hasPermi('slope:dataFile:edit')")
    @Log(title = "资料管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlopeDataFile slopeDataFile)
    {
        return toAjax(slopeDataFileService.updateSlopeDataFile(slopeDataFile));
    }

    /**
     * 删除资料管理
     */
    @PreAuthorize("@ss.hasPermi('slope:dataFile:remove')")
    @Log(title = "资料管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slopeDataFileService.deleteSlopeDataFileByIds(ids));
    }
}
